﻿@* DXCOMMENT: Configure GridView *@
@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "GridView";
        settings.CallbackRouteValues = new { Controller = "Account", Action = "AccountTypesGrid" };
        //settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Account", Action = "Delete" };
        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Account", Action = "Save" };
        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Account", Action = "Save" };
        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
        settings.SettingsPager.PageSize = 200;
        settings.Settings.ShowVerticalScrollBar = true;
        settings.Settings.VerticalScrollableHeight = 850;
        settings.SettingsBehavior.ConfirmDelete = true;
        
        settings.ControlStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
        settings.ControlStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
        settings.ControlStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
        
		// DXCOMMENT: Configure grid's columns in accordance with data model fields
        var operationsColumn = new MVCxGridViewCommandColumn { Caption = "Options" };
        operationsColumn.Width = System.Web.UI.WebControls.Unit.Pixel(96);
        operationsColumn.EditButton.Visible = true;
        //operationsColumn.DeleteButton.Visible = true;
        operationsColumn.Visible = true;
        operationsColumn.NewButton.Visible = true;
        settings.Columns.Add(operationsColumn);

        settings.Columns.Add(col =>
        {
            col.FieldName = "NMC_AccountTypeName";
            col.Caption = "Account Type";
        });

        settings.Columns.Add(col =>
        {
            col.FieldName = "Active";
            col.Caption = "Active";
            col.ColumnType = MVCxGridViewColumnType.ComboBox;


            ComboBoxProperties comboProperties = col.PropertiesEdit as ComboBoxProperties;
            comboProperties.DataSource = new Boolean[] { true, false };
        });
        
        settings.Columns.Add(col =>
        {
            col.FieldName = "LastModified";
            col.EditFormSettings.Visible = DefaultBoolean.False;
            col.ReadOnly = true;
        });

        settings.SettingsEditing.Mode = GridViewEditingMode.Inline;
        settings.KeyFieldName = "NMC_AccountTypeID";
        
    }).Bind(Model).GetHtml()